package day19;

public class demo3 {
    public static boolean solve (String A, String B) {
        if(A.length()!=B.length()){
            return false;
        }
        if(A.equals(B)){
            return true;
        }

        StringBuffer buf=new StringBuffer();

        for(int i=0;i<A.length();i++){
            buf.append(A.charAt(i));
            int pos=B.lastIndexOf(buf.toString());
            if(pos==(A.length()-i-1)){
             String t=A.substring(i+1,A.length());
                if(B.indexOf(t)==0){
                    return true;
                }
            }
        }
return false;
    }

    public static void main(String[] args) {
        System.out.println(solve("zhansan","sanzhan"));
    }


}
